﻿<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>公告</title>
<link rel="stylesheet" href="/scriptZIP/layui.min.css">
	<link rel="stylesheet" href="/css/common2.css" />
	<link rel="stylesheet" href="/css/layui.css" />
	<link rel="stylesheet" href="/scriptZIP/vue-select.min.css">

	<style>
		.layui-row {
			margin-top: 50px;
		}

		.layui-col-md-offset3 {
			margin-left: 10%;
		}

		.empty {
			border: none;
			outline: none;
			background-color: #8fbc8f;
			color: white;
			width: 100px;
			height: 35px;
			font-size: 18px;
			font-weight: bold;
			border-radius: 10px;
			line-height: 35px;
			text-align: center;
		}
	</style>
</head>

<body>
	<form id="form" method="post" ref="form" enctype="multipart/form-data" style="display: none">
		<input type="file" id="file" name="file" accept="image/*">
	</form>

	<div class="layui-row" id="vue-root">
		<button @click="item.agentIds=[]" class="empty">清空</button>
		<form class="layui-form">


			<div class="layui-col-md6 layui-col-md-offset3">

				<div class="layui-form-item">
					<label class="layui-form-label">标题</label>
					<div class="layui-input-block">
						<input autocomplete="off" placeholder="请输入标题" class="layui-input name" v-model="item.title">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">内容</label>
					<div class="layui-input-block" style="width: 150%;">
						<editor :init="init1" v-model="item.html" />
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">是否显示</label>
					<div class="layui-input-block" style="padding-top: 13px;line-height: 15px;">
						<input type="checkbox" v-model="item.show" style="display: unset;" />
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">代理商</label>
					<div class="layui-input-block">
						<v-select multiple placeholder="请选择代理商" label="name" :options="agents" :reduce="item=>item.id"
							v-model="item.agentIds"></v-select>
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<div class="offer" @click="submit">立即提交</div>
						<div class="return" onclick="history.back()">取消</div>
					</div>
				</div>
			</div>

		</form>
	</div>
	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>
	
	
	<script src="/scriptZIP/vue-select.min.js"></script>

	<script src="/scriptZIP/tinymce.min.js"></script>
	<script src="/lib/tinymce-vue.min.js"></script>
	<script src="/js/tinymce_image_plugin.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/item.js"></script>

	<script>
		var schoolId = 0;
		var field = 'history';

		Vue.component('v-select', VueSelect.VueSelect);

		var app = new Vue(merge({
			components: {
				editor: Editor,
			},
			data: {
				url: '/pc/history',
				init1: tinymceInit,
				item: {
					show: true,
					agentIds: []
				},
				agents: [],
			},
			created: function () {
				axios.get('/pc/agent/all').then(function (res) {
					this.agents = res.data;
					this.item.agentIds = this.agents.map(function (it) {
						return it.id;
					});
				}.bind(this));
				this.init();
			},
			watch: {
				'item.html': function (nv, ov) {
					replaceImg(this.item, 'html');
				}
			}
		}));

	</script>


</body>

</html>